# -*- coding: utf-8 -*-
# @Time    : 2019/10/15 13:56
# @Author  : LiHaowen
# @Email   : lihaowen2017@163.com
# @File    : private_method.py
from advanced.chapter03.class_method import Date


class User:

    def __init__(self, birthday):
        self.__birthday = birthday

    def get_age(self):
        # 返回年龄
        return 2019 - self.__birthday.year


class Student(User):
    def __init__(self, birthday):
        self.__birthday = birthday


if __name__ == '__main__':
    user = User(Date(1990, 2, 1))
    # print(user.__birthday)
    print(user._User__birthday)  # 私有属性只是将属性名修改,属性修改规则还可以避免同名属性
    print(user.get_age())

# 私有属性的访问只能在类中的公共方法进行访问，无法通过实例进行访问
